package com.fc.push.handler.pub;

import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Component;

import com.alibaba.fastjson.JSONObject;
import com.fc.push.handler.AbstractHttpHandler;
import com.fc.push.handler.HandlerResult;
import com.fc.remoting.anno.Protocol;
import com.fc.remoting.core.SessionManager;

@Component
@Protocol(module = PublishConst.PUBLISH_MODULE_ID,order= PublishConst.ORDER_3)
public class WebConnectHandler extends AbstractHttpHandler{
	private static final String CLIENT_ID = "clientid";
	private static final String CODE = "code";
	@Override
	public Object handle(HttpServletResponse response, JSONObject request) {
		String clientid = request.getString(CLIENT_ID);
		if(clientid == null || clientid.isEmpty()){
			JSONObject object = HandlerResult.result();
			object.put(CODE, MessageRCode.RCODE_ERROR_1002);
			return object;
		}
		SessionManager.putHttpChannel(clientid, response);
		return null;
	}

}
